//
//  CentralCache.hpp
//  高并发内存池
//
//  Created by 卜绎皓 on 2023/2/2.
//

#ifndef CentralCache_hpp
#define CentralCache_hpp

#include "Common.hpp"

#endif /* CentralCache_hpp */

//单例模式
class CentralCache
{
public:
    //提供一个全局访问点
    static CentralCache* GetInstance()
    {
        return &_sInst;
    }
    
    Span* GetOneSpan(SpanList& list, size_t byte_size);
    
    size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);
    
    
private:
    SpanList _spanLists[NFREELISTS];
private:
    CentralCache()
    {
        
    }
    
    CentralCache(const CentralCache&) = delete;
    
    static CentralCache _sInst;
};
